/**
 * Definition for singly-linked list.
 * function ListNode(val, next) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.next = (next===undefined ? null : next)
 * }
 */
/**
 * @param {ListNode} head
 * @return {number}
 */
 var pairSum = function(head) {
  let arr = [], c = head
  while(c){
    arr.push(c.val)
    c = c.next
  }
  let ans = 0
  const n = arr.length
  for(let i = 0; i<n/2; i++){
    ans = Math.max(ans, arr[i] + arr[n-1-i])
  }
  return ans
};